import json
from flask import Blueprint, request, Response
from src.modules.memory.service import HistoryRecordService

api = Blueprint("history_record", __name__)

@api.route("/history/records", methods = ['GET'])
def load_history_records():
    args = request.args
    list = HistoryRecordService.load_history_records(args)
    return Response(json.dumps({ "code": 200, "data": list }), status = 200, mimetype = "application/json")

@api.route("/history/update", methods = ['POST'])
def update_history_record():
    args = request.form
    HistoryRecordService.update_history_record(args)
    return Response(json.dumps({ "code": 200, "data": {} }), status = 200, mimetype = "application/json")

@api.route("/history/delete", methods = ['POST'])
def delete_history_record():
    args = request.form
    HistoryRecordService.delete_history_record(args)
    return Response(json.dumps({ "code": 200, "data": {} }), status = 200, mimetype = "application/json")
